﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyHealthOnline.Business;
using MyHealthOnline.Dal.Generated.EntityClasses;

namespace MyHealthOnline.Specialist.Controls
{
    public partial class EndConsult : System.Web.UI.UserControl
    {
        public int ConsultId
        {
            get
            {
                if (ViewState["ConsultId"] == null)
                {
                    return -1;
                }
                return Convert.ToInt32(ViewState["ConsultId"].ToString());
            }
            set
            {
                ViewState["ConsultId"] = value;
            }
        }
        
        public ConsultEntity Consult
        {
            get
            {
                return ConsultBusiness.GetConsult(ConsultId);
            }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnEnd_Click(object sender, EventArgs e)
        {
            ConsultBusiness.SaveConsult(Consult, txtConclusion.Text, txtSummary.Text, "Closed");
            txtConclusion.Text = "";
            txtSummary.Text = "";

            WebServiceHO webService = new WebServiceHO();
            webService.Notify(Consult.Specialist.Email, Consult.Pacient.Email,
                "Your consult with " + Consult.Specialist.Name + " is ended.",
                "Consult ended");
        }
    }
}